define(['app', 'omcall'], function(app) {
    'use strict';
    /*客户端首页控制器*/
    app.controller('Home', function($scope, $q, crmConst, omcall, $location, dataFactoryCRM) {
        $scope.dashboards;
        $scope.dashRcode;
        $scope.dashMsg;

        $scope.dataT; //部门业绩
        $scope.dataX; //团队业绩
        $scope.dataC; //时长统计
        $scope.dataXD; //新单业绩
        $scope.dataXF; //续费业绩
        $scope.dataK; //客户统计
        if ($location.path() == '/home') {
            $('#header').show();
        }
        /*if( !sessionStorage.showHomeNotify  ){
        	$('.home.nag').show();
        	sessionStorage.showHomeNotify  = 1;
        }

        dataFactoryCRM.getDataByAPI('index/index').then( function( _d ){
        	if( _d.rcode ){
        		$scope.logspage.pageAll = 2;
        		$scope.logs = _d.data;
        	}else{
        		console.log( _d );
        		//alert( _d.msg );
        	}
        });*/

        /*获取团队(同级)业绩*/
        $scope.$emit("BUSY");
        dataFactoryCRM.getDataByAPI('index/sector').then(function(data) {
            $scope.dashRcode = data.rcode;
            if (data.rcode) {
                $scope.dataT = data.dataT;
                $scope.dataX = data.dataX;
                $scope.dataC = data.dataC;
                $scope.dataXD = data.dataXD;
                $scope.dataXF = data.dataXF;
                $scope.dataK = data.dataK;
            } else {
                $scope.$emit("NOTBUSY");
                $scope.dashMsg = data.msg;
            }
            $scope.$emit("NOTBUSY");
        })
    });
});